import { defineStore } from 'pinia'
export const settingStore = defineStore('setting', {
    state: () => {
        const lang = localStorage.getItem('language')
        return {
            language: lang || 'zh',
            langList: [
                {
                    label: '中文简体',
                    value: 'zh'
                },
                {
                    label: 'English',
                    value: 'en'
                }
            ]
        }
    },
    getters: {
        // 注意getters里面声明的变量和state里面的变量不能重名
        getLanguage(state){ 
            return state.language
        },
        getLanguageList(state){
            return state.langList
        }
    },
    actions: {
        setLanguage(lang) {
            this.language = lang
            localStorage.setItem('language', lang)
        }
    }
})